<?php declare(strict_types=1);


namespace Database\Migration;

use Swoft\Devtool\Annotation\Mapping\Migration;
use Swoft\Devtool\Migration\Migration as BaseMigration;

/**
 * 第三方账户
 * 
 * Class AccountPlatform
 *
 * @since 2.0
 *
 * @Migration(time=20210713075739)
 */
class AccountPlatform extends BaseMigration
{
    /**
     * @return void
     */
    public function up(): void
    {
        $sql = <<<sql
CREATE TABLE `account_platform` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
    `uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '账号id',
    `platform_id` varchar(60) NOT NULL DEFAULT '' COMMENT '平台id',
    `platform_token` varchar(60) NOT NULL DEFAULT '' COMMENT '平台access_token',
    `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '平台类型 0:未知,1:facebook,2:google,3:wechat,4:qq,5:weibo,6:twitter',
    `nickname` varchar(60) NOT NULL DEFAULT '' COMMENT '昵称',
    `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
    `create_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
    `update_at` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_uid` (`uid`),
    KEY `idx_platform_id` (`platform_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='第三方用户信息';
sql;
        $this->execute($sql);
    }

    /**
     * @return void
     */
    public function down(): void
    {
        $dropSql = <<<sql
drop table if exists `account_platform`;
sql;
        $this->execute($dropSql);
    }
}
